﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Northwind.Objects
{
    public class Order : INotifyPropertyChanged
    {
        private Customer _Customer;
        public Customer Customer
        {
            get { return _Customer; }
            set
            {
                _Customer = value;
                OnPropertyChanged("Customer");
            }
        }

        private Employee _Employee;
        public Employee Employee
        {
            get { return _Employee; }
            set
            {
                _Employee = value;
                OnPropertyChanged("Employee");
            }
        }

        private string _OrderNo;
        public string OrderNo
        {
            get { return _OrderNo; }
            set
            {
                _OrderNo = value;
                OnPropertyChanged("OrderNo");
            }
        }

        private DateTime? _SaleDate;
        public DateTime? SaleDate
        {
            get { return _SaleDate; }
            set
            {
                _SaleDate = value;
                OnPropertyChanged("SaleDate");
            }
        }

        private IList<OrderDetail> _OrderDetails;
        public IList<OrderDetail> OrderDetails
        {
            get { return _OrderDetails; }
            set
            {
                _OrderDetails = value;
                OnPropertyChanged("OrderDetails");
            }
        }

        private decimal? _TotalMoney;
        public decimal? TotalMoney
        {
            get { return _TotalMoney; }
            set
            {
                _TotalMoney = value;
                OnPropertyChanged("TotalMoney");
            }
        }

        private int? _ProductCount;
        public int? ProductCount
        {
            get { return _ProductCount; }
            set
            {
                _ProductCount = value;
                OnPropertyChanged("ProductCount");
            }
        }

        public Order()
        {
            this.OrderDetails = new List<OrderDetail>();
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        // Create the OnPropertyChanged method to raise the event 
        public void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }

    public class OrderDetail : INotifyPropertyChanged
    {
        private Order _Order;
        public Order Order
        {
            get { return _Order; }
            set
            {
                _Order = value;
                OnPropertyChanged("Order");
            }
        }

        private int _SequenceOrder;
        public int SequenceOrder
        {
            get { return _SequenceOrder; }
            set
            {
                _SequenceOrder = value;
                OnPropertyChanged("SequenceOrder");
            }
        }

        private Product _Product;
        public Product Product
        {
            get { return _Product; }
            set
            {
                _Product = value;
                OnPropertyChanged("Product");
            }
        }

        private decimal _UnitPrice;
        public decimal UnitPrice
        {
            get { return _UnitPrice; }
            set
            {
                _UnitPrice = value;
                OnPropertyChanged("UnitPrice");
            }
        }

        private int _Quantity;
        public int Quantity
        {
            get { return _Quantity; }
            set
            {
                _Quantity = value;
                OnPropertyChanged("Quantity");
            }
        }

        private decimal _TotalPrice;
        public decimal TotalPrice
        {
            get { return _TotalPrice; }
            set
            {
                _TotalPrice = value;
                OnPropertyChanged("TotalPrice");
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        // Create the OnPropertyChanged method to raise the event 
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}
